# 一、创建一个圆Circle类，
# 为该类提供一个初始化方法，用于初始化半径
# 为该类提供两个方法，
# 方法一用 于求圆的面积，方法二用于求圆的周长
import math
import random


# class Circle(object):
#     def __init__(self, r):
#         self.r = r
#
#     def get_area(self):
#         return math.pi * self.r * self.r
#
#     def get_circumference(self):
#         return 2 * math.pi * self.r
#
#     def __str__(self):
#         return f"半径为{self.r}的面积为{self.get_area()},周长为{self.get_circumference()}"


# circle = Circle(random.randint(5, 10))
# print(circle)

# 封装圆形类，
# 包含数据，圆心(x,y)，半径(r)
# 包含方法，面积与周长
#
#
# 封装管理类，管理10个 半径位于10-30之间的圆  位置在【0，0， 100， 100】
# 封装方法
#     找到面积最大的圆
#     找到距离最远的两个圆
# class Circle:
#     def __init__(self, x, y, r):
#         self.x = x
#         self.y = y
#         self.r = r
#
#     def get_area(self):
#         return math.pi * self.r * self.r
#
#     def get_length(self):
#         return 2 * math.pi * self.r
#
#     def __str__(self):
#         return f"X:{self.x} Y:{self.y} R:{self.r} Area:{self.get_area()} Length:{self.get_length()}"
#
#
# class CircleManage:
#     def __init__(self):
#         self.circles = []
#
#     def add_circle(self, x, y, r):
#         c = Circle(x, y, r)
#         self.circles.append(c)
#
#     def show_all_circles(self):
#         for c in self.circles:
#             print(c)
#
#     def get_max_area(self):
#         # return max(self.circles, key=lambda c: c.get_area())
#
#         max_circles = []
#         max_area = 0
#
#         for c in self.circles:
#             if max_area < c.get_area():
#                 max_circles.clear()
#                 max_area = c.get_area()
#                 max_circles.append(c)
#
#             elif max_area == c.get_area():
#                 max_circles.append(c)
#
#         return max_circles
#
#     def get_max_length(self):
#         max_length = 0
#         circles = []
#         for i in range(len(self.circles) - 1):
#             for j in range(i + 1, len(self.circles)):
#                 dis = math.sqrt(
#                     (self.circles[i].x - self.circles[j].x) ** 2 + (self.circles[i].y - self.circles[j].y) ** 2)
#                 if max_length < dis:
#                     max_length = dis
#                     circles.clear()
#                     circles.append(self.circles[i])
#                     circles.append(self.circles[j])
#         return circles
#
#
# def main():
#     cm = CircleManage()
#     # cm.add_circle(1000, 1000, 30)
#     for i in range(10):
#         cm.add_circle(random.randint(0, 100), random.randint(0, 100), random.randint(10, 30))
#
#     cm.show_all_circles()
#     print("========")
#     max_circles = cm.get_max_area()
#     for c in max_circles:
#         print(f"面积最大的圆:{c}")
#     print("========")
#
#     for c in cm.get_max_length():
#         print(f"最大距离的圆{c}")
#
#
# main()


# 三、创建Rectangle类，初始化属性width、height；
# 在Rectangle类中添加两个方法计算矩形的周长和面积；
# 在Rectangle类中添加方法输出矩形的周长和面积
# 生成10个矩形 width,height都位于 5-10之间  求周长与面积之和最大的一个矩形

# class Rectangle:
#     def __init__(self, width, height):
#         self.width = width
#         self.height = height
#
#     def get_length(self):
#         return 2 * (self.width + self.height)
#
#     def get_area(self):
#         return self.width * self.height
#
#     def __str__(self):
#         return f"宽{self.width},高{self.height},周长{self.get_length()},面积{self.get_area()}"
#
#
# class RectangleManage:
#     def __init__(self):
#         self.l = []
#
#     def get_rect(self, width, height):
#         self.width = width
#         self.height = height
#         rect = {"width": self.width,
#                 "height": self.height
#                 }
#
#         self.l.append(rect)
#
#     def show_rect(self):
#         for i in self.l:
#             print(i)
#
#
# def main():
#     rm = RectangleManage()
#     for i in range(9):
#         r = Rectangle(width=random.randint(5, 10), height=random.randint(5, 10))
#         rm.get_rect(r.width, r.height)
#     rm.show_rect()
#
#
# main()


# is 和 == 的区别
# l = []
# l1 = []
# print(l == l1, l is l1)



